﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using LinqtoCRMApplication.CRM;
using System.IO;

namespace LinqtoCRM
{
    public class CrmDataContext
    {
        public IQueryable<contact> Contacts { get { return _contacts; } }
        public IQueryable<account> Accounts { get { return _accounts; } }

        private CrmQueryProvider _provider;
        private IQueryable<contact> _contacts;
        private IQueryable<account> _accounts;
        private IQueryable<customerrelationship> _relations;
        private ICrmService _service;
        
        public CrmDataContext(ICrmService service)
        {
            _service = service;
            _provider = new CrmQueryProvider(service);
            _contacts = new Query<contact>(_provider);
            _accounts = new Query<account>(_provider);
            _relations = new Query<customerrelationship>(_provider);
        }

        public CrmQueryProvider Provider 
        {
            get { return _provider; }
        }
        public TextWriter Log
        {
            get { return this._provider.Log; }
            set { this._provider.Log = value; }
        }       
    }
}
